package com.wjf.birdfish.util;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
 
public class ApplicationContextFactory {
	private static Log log = LogFactory.getLog(ApplicationContextFactory.class);
	
	private static ApplicationContext ac = null;
	public static ApplicationContext getApplicationContext(){
		if (ac == null){
			String contexts[] = {
					"spring/applicationContext.xml",
					"spring/dao.xml",
					"spring/service.xml",
					"spring/action.xml"};
			ac = new ClassPathXmlApplicationContext(contexts);
		}
		return ac;
	}
	
	public static void setAc(ApplicationContext ac) {
		ApplicationContextFactory.ac = ac;
		log.info("ApplicationContext is setted");
	}
}
